<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>月亮返照盘 | 情绪与内在成长预测</title>
    <style>
        /* 基础样式重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            /* 禁用移动端点击蒙层效果 */
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            outline: none;
        }

        /* 为可点击元素添加特定样式 */
        button,
        [class$="-btn"],
        .zodiac-sign,
        .chart-center,
        .planet,
        .house,
        a,
        [role="button"] {
            /* 禁用移动端点击蒙层效果 */
            -webkit-tap-highlight-color: transparent;
            tap-highlight-color: transparent;
            /* 防止文本选择 */
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            outline: none;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #0a0e17;
            color: #ffffff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 0;
            overflow-x: hidden;
            overflow-y: auto; /* 允许垂直滚动 */
        }
        
        /* 在iframe中显示时特殊处理 */
        body.in-iframe {
            padding: 20px;
        }

        /* 隐藏所有元素的滚动条但允许滚动 */
        html {
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE and Edge */
        }

        body {
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE and Edge */
        }

        /* Chrome, Safari and Opera */
        html::-webkit-scrollbar,
        body::-webkit-scrollbar {
            display: none;
        }

        /* 确保所有可滚动元素也隐藏滚动条 */
        * {
            scrollbar-width: none; /* Firefox */
        }

        *::-webkit-scrollbar {
            display: none; /* Chrome, Safari, Edge */
        }

        /* 页面标题 */
        header {
            text-align: center;
            margin-bottom: 30px;
            z-index: 10;
        }

        h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            background: linear-gradient(90deg, #9c27b0, #673ab7, #3f51b5, #2196f3);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            background-size: 300% 300%;
            animation: gradient 15s ease infinite;
        }

        @keyframes gradient {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .subtitle {
            color: #b2bec3;
            font-size: 1.1rem;
            max-width: 600px;
        }

        /* 出生信息表单 */
        .birth-info-form {
            background: rgba(17, 24, 39, 0.8);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 30px;
            width: 90%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .form-row {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-bottom: 15px;
        }

        .form-group {
            flex: 1;
            min-width: 200px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            color: #b2bec3;
            font-size: 0.9rem;
        }

        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            background: rgba(30, 41, 59, 0.8);
            color: white;
            font-size: 1rem;
        }

        .form-group input:focus {
            outline: 2px solid rgba(156, 39, 176, 0.8);
            outline-offset: 2px;
        }

        .calculate-btn {
            width: 100%;
            padding: 12px;
            background: linear-gradient(90deg, #9c27b0, #673ab7);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 1.1rem;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .calculate-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(156, 39, 176, 0.5);
        }

        /* 星盘容器 */
        .chart-container {
            position: relative;
            width: 90vw;
            max-width: 600px;
            height: 90vw;
            max-height: 600px;
            margin: 20px auto;
        }

        /* 星盘底座 */
        .chart-base {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: radial-gradient(circle, #39274d 0%, #0d1117 100%);
            box-shadow: 0 0 50px rgba(156, 39, 176, 0.3);
            overflow: hidden;
        }

        /* 宫位环 */
        .houses-ring {
            position: absolute;
            width: 90%;
            height: 90%;
            top: 5%;
            left: 5%;
            border-radius: 50%;
        }

        /* 星座环 */
        .zodiac-ring {
            position: absolute;
            width: 80%;
            height: 80%;
            top: 10%;
            left: 10%;
            border-radius: 50%;
        }

        /* 行星环 */
        .planets-ring {
            position: absolute;
            width: 70%;
            height: 70%;
            top: 15%;
            left: 15%;
            border-radius: 50%;
        }

        /* 宫位扇区 */
        .house {
            position: absolute;
            width: 50%;
            height: 50%;
            top: 0;
            left: 50%;
            transform-origin: bottom left;
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: flex-start;
            justify-content: center;
            padding-top: 10px;
        }

        .house-number {
            position: absolute;
            top: 15px;
            right: 15px;
            font-size: 0.9rem;
            font-weight: bold;
            color: #b2bec3;
        }

        /* 星座扇区 */
        .zodiac-sector {
            position: absolute;
            width: 50%;
            height: 50%;
            top: 0;
            left: 50%;
            transform-origin: bottom left;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .zodiac-sector-inner {
            position: relative;
            width: 100%;
            height: 100%;
            padding: 15% 10% 10% 10%;
        }

        .zodiac-sign {
            position: absolute;
            transform-origin: center;
            text-align: center;
            width: 50px;
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .zodiac-sign:hover {
            transform: scale(1.1);
        }

        .zodiac-icon {
            font-size: 1.2rem;
            margin-bottom: -10px;
            text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
            transform: translateY(20px);
        }

        /* 行星 */
        .planet {
            position: absolute;
            width: 25px;
            height: 25px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .planet:hover {
            transform: scale(1.2);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
        }

        .planet-icon {
            font-size: 0.9rem;
            color: white;
        }

        /* 星盘中心 */
        .chart-center {
            position: absolute;
            width: 15%;
            height: 15%;
            top: 42.5%;
            left: 42.5%;
            border-radius: 50%;
            background: radial-gradient(circle, #ffd600 0%, #9c27b0 100%);
            box-shadow: 0 0 20px rgba(156, 39, 176, 0.8);
            z-index: 5;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .chart-center:hover {
            transform: scale(1.05);
            box-shadow: 0 0 25px rgba(156, 39, 176, 0.9);
        }

        .chart-center::after {
            content: '☾';
            font-size: 1.5rem;
            color: white;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
        }

        /* 方向标记 */
        .direction {
            position: absolute;
            z-index: 4;
            font-weight: bold;
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
        }

        .north {
            top: 2%;
            left: 50%;
            transform: translateX(-50%);
            color: #ff5252;
        }

        .east {
            top: 50%;
            right: 2%;
            transform: translateY(-50%);
            color: #4caf50;
        }

        .south {
            bottom: 2%;
            left: 50%;
            transform: translateX(-50%);
            color: #2196f3;
        }

        .west {
            top: 50%;
            left: 2%;
            transform: translateY(-50%);
            color: #9c27b0;
        }

        /* 信息面板 */
        .info-content {
            background: rgba(17, 24, 39, 0.8);
            backdrop-filter: blur(10px);
            border-radius: 12px;
            padding: 20px;
            margin-top: 30px;
            width: 100%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .info-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
            overflow-x: auto;
            padding-bottom: 10px;
        }

        .info-tab {
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
            white-space: nowrap;
        }

        .info-tab:hover {
            background: rgba(59, 130, 246, 0.3);
        }

        .info-tab.active {
            background: rgba(59, 130, 246, 0.8);
            border-color: #3b82f6;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .info-header {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            padding-bottom: 10px;
        }

        .info-icon {
            font-size: 2rem;
            margin-right: 15px;
        }

        .info-title {
            flex-grow: 1;
        }

        .info-name {
            font-size: 1.5rem;
            margin-bottom: 5px;
        }

        .info-details {
            color: #b2bec3;
            font-size: 0.9rem;
        }

        .info-text {
            font-size: 1rem;
            line-height: 1.6;
            color: #e9ecef;
            margin-bottom: 15px;
        }

        /* 信息卡片样式 */
        .info-card {
            background: rgba(255, 255, 255, 0.05);
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 15px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.3s ease;
        }

        .info-card:hover {
            background: rgba(255, 255, 255, 0.08);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .info-card-title {
            font-size: 1.2rem;
            margin-bottom: 10px;
            font-weight: 600;
        }

        /* 控制按钮 */
        .controls-container {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
            margin: 20px 0;
        }

        .controls {
            display: flex;
            gap: 10px;
        }

        .control-btn {
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: white;
            padding: 10px 14px;
            border-radius: 22px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 1.0rem;
            min-width: 80px;
        }

        .control-btn:hover {
            background: rgba(59, 130, 246, 0.5);
            transform: translateY(-2px);
        }

        /* 添加按钮点击时的选中效果 */
        .control-btn:active {
            transform: scale(0.95);
            background: rgba(59, 130, 246, 0.8);
        }

        .control-btn:focus {
            outline: 2px solid rgba(59, 130, 246, 0.8);
            outline-offset: 2px;
        }

        /* 添加选中状态样式 */
        .control-btn.selected {
            background: rgba(59, 130, 246, 0.8);
            border-color: rgba(255, 255, 255, 0.5);
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
        }

        .control-btn.reset {
            background: rgba(239, 68, 68, 0.3);
        }

        .control-btn.reset:active {
            background: rgba(239, 68, 68, 0.6);
        }

        .control-btn.reset.selected {
            background: rgba(239, 68, 68, 0.6);
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
        }

        .control-btn.spin {
            background: rgba(34, 197, 94, 0.3);
        }

        .control-btn.spin:active {
            background: rgba(34, 197, 94, 0.6);
        }

        .control-btn.spin.selected {
            background: rgba(34, 197, 94, 0.6);
            box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
        }

        /* 星星背景 */
        .stars {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            overflow: hidden;
        }

        .star {
            position: absolute;
            background: white;
            border-radius: 50%;
            animation: twinkle 2s infinite;
        }

        @keyframes twinkle {
            0% {
                opacity: 0.2;
                transform: scale(0.8);
            }
            50% {
                opacity: 1;
                transform: scale(1);
            }
            100% {
                opacity: 0.2;
                transform: scale(0.8);
            }
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            h1 {
                font-size: 2rem;
            }

            .subtitle {
                font-size: 1rem;
                padding: 0 20px;
            }

            .form-group {
                min-width: 100%;
            }

            .chart-container {
                width: 95vw;
                height: 95vw;
            }
        }


    </style>
</head>
<body>
    <!-- 星星背景 -->
    <div class="stars"></div>

    <header>
        <h1>月亮返照盘</h1>
        <p class="subtitle">探索你的情绪世界与内在成长周期，预测28天内的情感波动与内心变化</p>
    </header>

    <div class="birth-info-form">
        <form>
            <div class="form-row">
                <div class="form-group">
                    <label for="birthDate">出生日期</label>
                    <input type="date" id="birthDate" required>
                </div>
                <div class="form-group">
                    <label for="birthTime">出生时间</label>
                    <input type="time" id="birthTime" required>
                </div>
            </div>
            <div class="form-row">
                <div class="form-group">
                    <label for="birthPlace">出生地点</label>
                    <input type="text" id="birthPlace" placeholder="城市/地区" required>
                </div>
                <div class="form-group">
                    <label for="lunarPhase">关注月相</label>
                    <input type="date" id="lunarPhase">
                </div>
            </div>
            <button type="button" class="calculate-btn" id="calculateBtn">计算月亮返照盘</button>
        </form>
    </div>

    <div class="chart-container">
        <div class="chart-base" id="chartBase">
            <div class="direction north">北</div>
            <div class="direction east">东</div>
            <div class="direction south">南</div>
            <div class="direction west">西</div>
            
            <div class="houses-ring" id="housesRing"></div>
            <div class="zodiac-ring" id="zodiacRing"></div>
            <div class="planets-ring" id="planetsRing"></div>
            
            <div class="chart-center" id="chartCenter"></div>
            
            <div style="position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); text-align: center; color: #b2bec3;">
                <div>上升星座: <span id="ascendantValue">♈ 0°</span></div>
            </div>
        </div>
    </div>

    <!-- 控制按钮区域 -->
    <div class="controls-container">
        <div class="controls">
            <div class="controls-row">
                <button class="control-btn reset" id="resetBtn">重置</button>
                <button class="control-btn spin" id="rotateBtn">旋转星盘</button>
            </div>
        </div>
    </div>

    <!-- 信息面板 -->
    <div class="info-content">
        <div class="info-tabs">
            <button class="info-tab active" data-tab="overview">概览解析</button>
            <button class="info-tab" data-tab="zodiac">星座解析</button>
            <button class="info-tab" data-tab="houses">宫位解析</button>
            <button class="info-tab" data-tab="planets">行星解析</button>
        </div>
        
        <div id="overview" class="tab-content active">
            <div class="info-header">
                <div class="info-icon">☾</div>
                <div class="info-title">
                    <div class="info-name">月亮返照盘概览</div>
                    <div class="info-details">情绪周期预测与内在成长</div>
                </div>
            </div>
            <div class="info-text">
                <p>月亮返照盘是一种特殊的星盘，用于预测一个人在未来28天（月亮运行周期）内的情绪变化、内心状态和潜意识活动。它基于月亮回到出生时的准确位置时的星象绘制。</p>
                <p>这个星盘可以揭示你在接下来的情绪周期中可能面临的情感挑战、内心成长机遇和潜意识需求。通过了解月亮返照盘，你可以更好地理解自己的情绪模式，提高情绪管理能力。</p>
                <p id="chartSummary">请输入出生信息并点击计算按钮以获取详细分析。</p>
            </div>
        </div>
        
        <div id="zodiac" class="tab-content">
            <div class="info-header">
                <div class="info-icon">♈</div>
                <div class="info-title">
                    <div class="info-name">星座解析</div>
                    <div class="info-details">月亮在不同星座的影响</div>
                </div>
            </div>
            <div class="info-text">
                <p>点击星盘上的星座区域查看详细解析。月亮在不同星座的位置揭示了你的情绪表达方式和内心需求。</p>
                <div id="zodiacInfo"></div>
            </div>
        </div>
        
        <div id="houses" class="tab-content">
            <div class="info-header">
                <div class="info-icon">🏠</div>
                <div class="info-title">
                    <div class="info-name">宫位解析</div>
                    <div class="info-details">情绪关注的生活领域</div>
                </div>
            </div>
            <div class="info-text">
                <p>点击星盘上的宫位区域查看详细解析。月亮在不同宫位的位置揭示了你在情绪周期中关注的生活领域。</p>
                <div id="houseInfo"></div>
            </div>
        </div>
        
        <div id="planets" class="tab-content">
            <div class="info-header">
                <div class="info-icon">🪐</div>
                <div class="info-title">
                    <div class="info-name">行星解析</div>
                    <div class="info-details">情绪与潜意识的交互</div>
                </div>
            </div>
            <div class="info-text">
                <p>点击星盘上的行星查看详细解析。行星与月亮的相位关系揭示了你的情绪能量如何与其他生命领域相互作用。</p>
                <div id="planetInfo"></div>
            </div>
        </div>
    </div>

    <script>
        // 星座数据
        const zodiacSigns = [
            { name: '白羊座', symbol: '♈', color: '#ff5252' },
            { name: '金牛座', symbol: '♉', color: '#4caf50' },
            { name: '双子座', symbol: '♊', color: '#ffeb3b' },
            { name: '巨蟹座', symbol: '♋', color: '#ff9800' },
            { name: '狮子座', symbol: '♌', color: '#ffc107' },
            { name: '处女座', symbol: '♍', color: '#8bc34a' },
            { name: '天秤座', symbol: '♎', color: '#2196f3' },
            { name: '天蝎座', symbol: '♏', color: '#f44336' },
            { name: '射手座', symbol: '♐', color: '#ffc107' },
            { name: '摩羯座', symbol: '♑', color: '#795548' },
            { name: '水瓶座', symbol: '♒', color: '#03a9f4' },
            { name: '双鱼座', symbol: '♓', color: '#9c27b0' }
        ];

        // 行星数据
        const planets = [
            { name: '太阳', symbol: '☉', color: '#ffeb3b' },
            { name: '月亮', symbol: '☾', color: '#e0e0e0' },
            { name: '水星', symbol: '☿', color: '#9e9e9e' },
            { name: '金星', symbol: '♀', color: '#ff4081' },
            { name: '火星', symbol: '♂', color: '#f44336' },
            { name: '木星', symbol: '♃', color: '#8bc34a' },
            { name: '土星', symbol: '♄', color: '#795548' },
            { name: '天王星', symbol: '♅', color: '#00bcd4' },
            { name: '海王星', symbol: '♆', color: '#9c27b0' },
            { name: '冥王星', symbol: '♇', color: '#795548' },
            { name: '上升点', symbol: '↑', color: '#2196f3' },
            { name: '中天', symbol: 'MC', color: '#673ab7' }
        ];

        // 宫位数据
        const houses = [
            { number: 1, name: '命宫', meaning: '自我认同与个人形象' },
            { number: 2, name: '财帛宫', meaning: '物质财富与价值观' },
            { number: 3, name: '兄弟宫', meaning: '沟通交流与学习能力' },
            { number: 4, name: '田宅宫', meaning: '家庭生活与安全感' },
            { number: 5, name: '子女宫', meaning: '创造力与娱乐休闲' },
            { number: 6, name: '奴仆宫', meaning: '工作习惯与健康状况' },
            { number: 7, name: '夫妻宫', meaning: '亲密关系与合作伙伴' },
            { number: 8, name: '疾厄宫', meaning: '心灵成长与深层转变' },
            { number: 9, name: '迁移宫', meaning: '长途旅行与高等教育' },
            { number: 10, name: '官禄宫', meaning: '事业成就与社会地位' },
            { number: 11, name: '福德宫', meaning: '社交网络与人生目标' },
            { number: 12, name: '玄秘宫', meaning: '潜意识与精神世界' }
        ];

        // 生成星座信息显示
        function showZodiacInfo(zodiacIndex) {
            const zodiacInfo = document.getElementById('zodiacInfo');
            const zodiac = zodiacSigns[zodiacIndex];
            zodiacInfo.innerHTML = `
                <div class="info-card">
                    <h4 class="info-card-title" style="color: ${zodiac.color};">${zodiac.symbol} ${zodiac.name}</h4>
                    <p>在月亮返照盘中，月亮位于${zodiac.name}，这意味着你在接下来的情绪周期中将以${zodiac.name}特有的方式表达情感和满足内心需求。</p>
                    <p>${zodiac.name}的能量将影响你的情绪反应模式和内心安全感的来源。了解这种能量可以帮助你更好地理解和接纳自己的情绪变化。</p>
                </div>
            `;
        }

        // 生成宫位信息显示
        function showHouseInfo(houseNumber) {
            const houseInfo = document.getElementById('houseInfo');
            const house = houses[houseNumber - 1];
            houseInfo.innerHTML = `
                <div class="info-card">
                    <h4 class="info-card-title" style="color: #9c27b0;">第${house.number}宫：${house.name}</h4>
                    <p>在月亮返照盘中，月亮位于第${house.number}宫，这意味着你在情绪周期中将特别关注${house.meaning}领域。</p>
                    <p>这个宫位的能量将是你情绪波动的主要来源，也是你内心成长和自我探索的重点领域。</p>
                </div>
            `;
        }

        // 生成行星信息显示
        function showPlanetInfo(planetIndex) {
            const planetInfo = document.getElementById('planetInfo');
            const planet = planets[planetIndex];
            planetInfo.innerHTML = `
                <div class="info-card">
                    <h4 class="info-card-title" style="color: ${planet.color};">${planet.symbol} ${planet.name}</h4>
                    <p>在月亮返照盘中，${planet.name}与月亮的相位关系揭示了你的情绪能量如何与${planet.name}所代表的生命领域相互作用。</p>
                    <p>观察${planet.name}的位置和相位，可以帮助你理解情绪变化的深层原因，以及如何更好地应对情绪挑战。</p>
                </div>
            `;
        }

        // 根据度数获取星座
        function getZodiacByDegrees(degrees) {
            const normalizedDegrees = degrees % 360;
            const index = Math.floor(normalizedDegrees / 30);
            return zodiacSigns[index];
        }

        // 切换信息选项卡
        function switchTab(tabId) {
            const tabs = document.querySelectorAll('.info-tab');
            const tabContents = document.querySelectorAll('.tab-content');

            tabs.forEach(tab => {
                tab.classList.remove('active');
                if (tab.getAttribute('data-tab') === tabId) {
                    tab.classList.add('active');
                }
            });

            tabContents.forEach(content => {
                content.classList.remove('active');
                if (content.id === tabId) {
                    content.classList.add('active');
                }
            });
        }

        // 旋转星盘
        function rotateChart(degrees) {
            const chartBase = document.getElementById('chartBase');
            const currentRotation = getComputedStyle(chartBase).transform;
            
            let matrix = new DOMMatrix(currentRotation);
            let angle = Math.atan2(matrix.b, matrix.a) * 180 / Math.PI;
            
            angle += degrees;
            chartBase.style.transform = `rotate(${angle}deg)`;
        }

        // 计算月亮返照盘
        function calculateLunarReturnChart() {
            const birthDate = document.getElementById('birthDate').value;
            const birthTime = document.getElementById('birthTime').value;
            const birthPlace = document.getElementById('birthPlace').value;
            const lunarPhaseDate = document.getElementById('lunarPhase').value;
            
            if (!birthDate) {
                alert('请输入出生日期');
                return;
            }
            
            if (!birthTime) {
                alert('请输入出生时间');
                return;
            }
            
            if (!birthPlace) {
                alert('请输入出生地点');
                return;
            }
            
            // 模拟计算结果（实际应用中应使用天文算法）
            const birthDateObj = new Date(birthDate);
            const today = new Date();
            
            // 模拟月亮返照日期（实际应用中应使用天文算法计算）
            // 这里简单地使用距离出生日期最近的满月作为返照日期
            let lunarReturnDate;
            if (lunarPhaseDate) {
                lunarReturnDate = new Date(lunarPhaseDate);
            } else {
                // 如果没有指定月相日期，使用当前日期
                lunarReturnDate = today;
            }
            
            // 显示计算结果
            document.getElementById('chartSummary').innerHTML = `
                <p><strong>计算信息：</strong></p>
                <p>出生日期：${birthDate}</p>
                <p>出生时间：${birthTime}</p>
                <p>出生地点：${birthPlace}</p>
                <p>关注月相日期：${lunarPhaseDate || '当前日期'}</p>
                <p style="margin-top: 15px;"><strong>月亮返照盘解读：</strong></p>
                <p>在这个情绪周期中，月亮位于${getZodiacByDegrees(Math.random() * 360).name}座，这意味着你的情绪表达和内心需求将受到${getZodiacByDegrees(Math.random() * 360).name}能量的影响。</p>
                <p>通过分析星盘中行星与月亮的相位关系，可以深入了解你在情绪、关系、创造力和内心成长等方面可能经历的变化和机遇。</p>
            `;
            
            // 渲染星盘
            renderChart();
        }

        // 渲染星盘
        function renderChart() {
            const housesRing = document.getElementById('housesRing');
            const zodiacRing = document.getElementById('zodiacRing');
            const planetsRing = document.getElementById('planetsRing');
            
            // 清空现有内容
            housesRing.innerHTML = '';
            zodiacRing.innerHTML = '';
            planetsRing.innerHTML = '';
            
            // 生成宫位
            const houseAngle = 30; // 每个宫位30度
            for (let i = 0; i < 12; i++) {
                const house = document.createElement('div');
                house.classList.add('house');
                house.style.transform = `rotate(${i * houseAngle}deg)`;
                
                // 创建宫位标签
                const houseNumber = document.createElement('div');
                houseNumber.classList.add('house-number');
                houseNumber.style.position = 'absolute';
                houseNumber.style.top = '10%';
                houseNumber.style.left = '50%';
                houseNumber.style.transform = 'translate(-50%, -50%) rotate(-' + (i * houseAngle) + 'deg)';
                houseNumber.style.color = '#ffffff';
                houseNumber.style.fontSize = '1rem';
                houseNumber.style.fontWeight = 'bold';
                houseNumber.textContent = (i + 1);
                
                house.appendChild(houseNumber);
                house.addEventListener('click', () => {
                    showHouseInfo(i + 1);
                    switchTab('houses');
                });
                housesRing.appendChild(house);
            }
            
            // 生成星座
            const zodiacAngle = 30; // 每个星座30度
            for (let i = 0; i < 12; i++) {
                const zodiac = document.createElement('div');
                zodiac.classList.add('zodiac-sector');
                zodiac.style.transform = `rotate(${i * zodiacAngle}deg)`;
                zodiac.style.background = `linear-gradient(45deg, rgba(0,0,0,0.1), ${zodiacSigns[i].color}40)`;
                
                // 创建星座符号
                const sign = document.createElement('div');
                sign.classList.add('zodiac-sign');
                sign.style.top = '30%';
                sign.style.left = '50%';
                sign.style.transform = `translate(-50%, -50%) rotate(-${i * zodiacAngle}deg)`;
                sign.textContent = zodiacSigns[i].symbol;
                sign.style.color = zodiacSigns[i].color;
                
                zodiac.appendChild(sign);
                zodiac.addEventListener('click', () => {
                    showZodiacInfo(i);
                    switchTab('zodiac');
                });
                zodiacRing.appendChild(zodiac);
            }
            
            // 生成行星
            for (let i = 0; i < planets.length; i++) {
                const planet = document.createElement('div');
                planet.classList.add('planet');
                
                // 随机位置（实际应用中应根据计算结果）
                const angle = Math.random() * 360;
                const radius = 65; // 行星环半径百分比
                
                const radians = angle * Math.PI / 180;
                const centerX = 50;
                const centerY = 50;
                const x = centerX + radius * Math.cos(radians);
                const y = centerY + radius * Math.sin(radians);
                
                planet.style.left = `${x}%`;
                planet.style.top = `${y}%`;
                planet.style.background = planets[i].color;
                planet.textContent = planets[i].symbol;
                
                planet.addEventListener('click', () => {
                    showPlanetInfo(i);
                    switchTab('planets');
                });
                planetsRing.appendChild(planet);
            }
            
            // 随机生成上升星座（实际应用中应根据计算结果）
            const ascendantDegree = Math.random() * 360;
            const ascendantZodiac = getZodiacByDegrees(ascendantDegree);
            document.getElementById('ascendantValue').textContent = `${ascendantZodiac.symbol} ${Math.round(ascendantDegree)}°`;
        }

        // 创建星星背景
        function createStars() {
            const starsContainer = document.querySelector('.stars');
            const starCount = 150; // 星星数量
            
            for (let i = 0; i < starCount; i++) {
                const star = document.createElement('div');
                star.classList.add('star');
                
                // 随机位置
                const x = Math.random() * 100;
                const y = Math.random() * 100;
                
                // 随机大小
                const size = Math.random() * 2 + 0.5;
                
                // 随机动画延迟
                const delay = Math.random() * 2;
                
                // 设置样式
                star.style.left = `${x}%`;
                star.style.top = `${y}%`;
                star.style.width = `${size}px`;
                star.style.height = `${size}px`;
                star.style.animationDelay = `${delay}s`;
                
                starsContainer.appendChild(star);
            }
        }

        // 优化滑动体验
        function optimizeScrolling() {
            // 1. 通过CSS设置触摸行为，允许垂直滑动
            document.body.style.touchAction = 'pan-y';
            document.body.style.overscrollBehavior = 'contain';
            
            // 1.1 确保星星背景不会覆盖内容
            const starsBackground = document.querySelector('.stars');
            if (starsBackground) {
                starsBackground.style.zIndex = '-1';
            }

            // 2. 定义变量用于触摸控制
            let startX = null;
            let startY = null;
            let isVerticalScrolling = false;
            const HORIZONTAL_THRESHOLD = 10; // 放宽水平滑动检测阈值
            const VERTICAL_MIN_DISTANCE = 5; // 垂直滑动最小距离

            // 触摸开始事件
            document.addEventListener('touchstart', (e) => {
                startX = e.touches[0].clientX;
                startY = e.touches[0].clientY;
                isVerticalScrolling = false;
            }, { passive: true });

            // 触摸移动事件 - 优化版，优先保证垂直滑动体验
            document.addEventListener('touchmove', (e) => {
                if (!startX || !startY) return;

                // 计算滑动距离
                const touchX = e.touches[0].clientX;
                const touchY = e.touches[0].clientY;
                const diffX = Math.abs(touchX - startX);
                const diffY = Math.abs(touchY - startY);

                // 确定是否为垂直滚动
                if (!isVerticalScrolling && diffY > VERTICAL_MIN_DISTANCE) {
                    isVerticalScrolling = true;
                }

                // 只有当明显是水平滑动时才阻止
                if (!isVerticalScrolling && diffX > HORIZONTAL_THRESHOLD && diffX > diffY) {
                    e.preventDefault();
                }
                // 如果已经确定为垂直滚动，则允许继续滚动
                // 这里不使用passive: false可以提高性能
            }, { passive: true });

            // 3. 手势处理 - 只在必要时阻止
            document.addEventListener('gesturestart', (e) => {
                e.preventDefault();
            }, { passive: false });

            // 4. 优化水平位置控制 - 减少过度干预
            let lastScrollTime = 0;
            const SCROLL_DELAY = 50; // 滚动事件防抖延迟

            window.addEventListener('scroll', () => {
                const now = Date.now();
                // 防抖处理，避免过于频繁地干预滚动
                if (now - lastScrollTime > SCROLL_DELAY && window.scrollX !== 0) {
                    lastScrollTime = now;
                    window.scrollTo(0, window.scrollY);
                }
            }, { passive: true });

            // 5. 确保body可以自由扩展高度
            document.body.style.minHeight = '100vh';
            document.documentElement.style.minHeight = '100vh';
            
            // 6. 确保内容可以垂直滚动
            document.body.style.overflowY = 'auto';
            document.documentElement.style.overflowY = 'auto';

            // 7. 为信息面板添加额外的滚动保障
            const infoContent = document.querySelector('.info-content');
            if (infoContent) {
                infoContent.style.zIndex = '10';
                infoContent.style.position = 'relative';
                infoContent.style.overflowY = 'auto';
                // 确保信息面板在移动设备上有足够的空间显示
                if (window.innerWidth <= 768) {
                    infoContent.style.marginBottom = '50px';
                }
            }
            
            // 8. 为信息选项卡区域添加横向滚动支持
            const infoTabs = document.querySelector('.info-tabs');
            if (infoTabs) {
                infoTabs.style.scrollBehavior = 'smooth';
            }
            
            // 9. 在移动设备上添加额外的底部空间，确保内容不被遮挡
            const addMobileBottomSpace = () => {
                if (window.innerWidth <= 768) {
                    document.body.style.paddingBottom = '100px'; // 增加底部padding，确保内容不被遮挡
                } else {
                    document.body.style.paddingBottom = '0';
                }
            };
            
            // 初始调用一次
            addMobileBottomSpace();
            
            // 监听窗口大小变化
            window.addEventListener('resize', addMobileBottomSpace);
        }

        // 添加事件监听器
        function addEventListeners() {
            // 计算按钮
            document.getElementById('calculateBtn').addEventListener('click', calculateLunarReturnChart);
            
            // 控制按钮
            document.getElementById('rotateBtn').addEventListener('click', () => rotateChart(90));
            document.getElementById('resetBtn').addEventListener('click', () => {
                document.getElementById('chartBase').style.transform = 'rotate(0deg)';
            });
            
            // 信息选项卡
            document.querySelectorAll('.info-tab').forEach(tab => {
                tab.addEventListener('click', () => {
                    const tabId = tab.getAttribute('data-tab');
                    switchTab(tabId);
                });
            });
            
            // 自动设置默认日期
            setDefaultDate();
        }

        // 设置默认日期为今天
        function setDefaultDate() {
            const today = new Date();
            const year = today.getFullYear();
            const month = String(today.getMonth() + 1).padStart(2, '0');
            const day = String(today.getDate()).padStart(2, '0');
            const formattedDate = `${year}-${month}-${day}`;
            
            document.getElementById('birthDate').value = formattedDate;
            document.getElementById('birthTime').value = '12:00';
            document.getElementById('lunarPhase').value = formattedDate;
        }

        // 初始化页面
        function init() {
            createStars();
            addEventListeners();
            optimizeScrolling();
            
            // 如果是在iframe中加载，添加in-iframe类并优化滚动
            if (window.self !== window.top) {
                document.body.classList.add('in-iframe');
                // 确保iframe中能正常滚动
                document.body.style.height = 'auto';
                document.documentElement.style.height = 'auto';
                document.body.style.overflowY = 'auto';
                document.documentElement.style.overflowY = 'auto';
            }
            
            // 延迟300毫秒后自动触发计算，确保DOM完全加载
            setTimeout(() => {
                // 设置默认的出生地点
                if (!document.getElementById('birthPlace').value) {
                    document.getElementById('birthPlace').value = '北京';
                }
                // 触发计算按钮点击
                document.getElementById('calculateBtn').click();
            }, 300);
        }

        // 页面加载完成后初始化
        window.addEventListener('load', init);
    </script>
</body>
</html>